Skip to content

Fix hfield transform - #879

Open
conlain-k wants to merge 4 commits into
coal-library:develfrom
conlain-k:fix_hfield_transform
Open

Fix hfield transform#879
conlain-k wants to merge 4 commits into
coal-library:develfrom
conlain-k:fix_hfield_transform

Conversation

@conlain-k

Copy link
Copy Markdown

Fix heightfield contact correction for transformed heightfields

First, thank you to the developers for your hard work on Coal.

I noticed an issue in the witness-point calculations for heightfields and believe I have narrowed down a fix. This may also be related to #654.

Problem

The heightfield-specific binCorrection() path mixed heightfield-local bin geometry with world-space contact and support points. Existing identity-pose tests did not expose the mismatch. I originally encountered this on version 3.0.1 and reproduced it on the devel branch as well.

For example, colliding a sphere near the center of a translated flat heightfield returned a witness in its local coordinates, rather than world coordinates:

actual:   [0.09, -0.11, 0]
expected: [2.05, -2.07, 0]

In this failure path the penetration depth can still be correct, which made the problem easy to miss. Rotated heightfields could also return an incorrectly transformed normal.

Reproduction

The new test case in hfields.cpp compares a flat HeightField<OBBRSS> with an analytically equivalent box under identity, translated, and translated-and-rotated poses. It checks penetration, both witnesses, and the contact normal using the default CollisionRequest settings.

The test fails on devel before this change and passes with the fix applied.

Fix

This change performs face selection, support mapping, and projection in the heightfield-local frame. It then transforms the corrected witnesses and normal back to world space. The public heightfield API is unchanged.

@jorisv

jorisv commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Hello @conlain-k,

Thanks for the contribution. Right now, we don't have the time to review it but we will come back to you around September.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants